package io.geekidea.springbootplus.system.service.impl;

import io.geekidea.springbootplus.system.entity.Schoolconfig;
import io.geekidea.springbootplus.system.mapper.SchoolconfigMapper;
import io.geekidea.springbootplus.system.service.SchoolconfigService;
import io.geekidea.springbootplus.system.param.SchoolconfigPageParam;
import io.geekidea.springbootplus.system.vo.SchoolconfigQueryVo;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.Serializable;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import java.util.List;
/**
 *  服务实现类
 *
 * @author miko
 * @since 2020-11-16
 */
@Slf4j
@Service
public class SchoolconfigServiceImpl extends BaseServiceImpl<SchoolconfigMapper, Schoolconfig> implements SchoolconfigService {

    @Autowired
    private SchoolconfigMapper schoolconfigMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean saveSchoolconfig(Schoolconfig schoolconfig) throws Exception {
        return super.save(schoolconfig);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean updateSchoolconfig(Schoolconfig schoolconfig) throws Exception {
        return super.updateById(schoolconfig);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteSchoolconfig(Long id) throws Exception {
        return super.removeById(id);
    }


    @Override
    public List<Schoolconfig> getAllList(LambdaQueryWrapper<Schoolconfig> wrapper) throws Exception{
        return schoolconfigMapper.selectList(wrapper);
    }



    @Override
    public SchoolconfigQueryVo getSchoolconfigById(Serializable id) throws Exception {
    return schoolconfigMapper.getSchoolconfigById(id);
    }

    @Override
    public Paging<SchoolconfigQueryVo> getSchoolconfigPageList(SchoolconfigPageParam schoolconfigPageParam) throws Exception {
        Page<SchoolconfigQueryVo> page = new PageInfo<>(schoolconfigPageParam, OrderItem.desc(getLambdaColumn(Schoolconfig::getCreateTime)));
        IPage<SchoolconfigQueryVo> iPage = schoolconfigMapper.getSchoolconfigPageList(page, schoolconfigPageParam);
        return new Paging<SchoolconfigQueryVo>(iPage);
    }

}
